package com.hanrui.android.fragment.message.audit.receipt;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.hanrui.android.R;
import com.hanrui.android.activity.download.MyDownLoadActivity;
import com.hanrui.android.library.base.BaseFragment;
import com.hanrui.android.model.ReceiptDocDetailBean;
import com.hanrui.android.net.contract.message.audit.receipt.ReceiptDocDetailContract;
import com.hanrui.android.net.presenter.message.audit.receipt.ReceiptDocDetailPresenter;

import butterknife.BindView;

/**
 * 收文审批基本信息
 *
 */

public class ReceiptDocDetailFragment extends BaseFragment<ReceiptDocDetailPresenter> implements ReceiptDocDetailContract.View {
    @BindView(R.id.main_title)
    TextView mainTitle;
    @BindView(R.id.subhead_title)
    TextView subheadTitle;
    @BindView(R.id.enclosure_ll)
    LinearLayout enclosureLl;
    @BindView(R.id.enclosure)
    ImageView enclosure;
    @BindView(R.id.name)
    TextView name;
    @BindView(R.id.thing_title)
    TextView thingTitle;
    @BindView(R.id.time)
    TextView time;
    @BindView(R.id.page_num)
    TextView pageNum;
    @BindView(R.id.copies_num)
    TextView copiesNum;
    @BindView(R.id.vote_meet)
    TextView voteMeet;
    @BindView(R.id.duty_people)
    TextView dutyPeople;
    @BindView(R.id.money_meet)
    TextView moneyMeet;
    @BindView(R.id.wind_meet)
    TextView windMeet;
    @BindView(R.id.receipt_num)
    TextView receiptNum;
    @BindView(R.id.receipt_page)
    TextView receiptPage;
    @BindView(R.id.enclosure_num)
    TextView enclosureNum;

    String taskId,procInsId,bizId;

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_receiptdocdetail;
    }

    @Override
    protected void initInjector() { mFragmentComponent.inject(this); }

    @Override
    protected void initView(View view) {

        taskId = getArguments().getString("taskId");
        procInsId = getArguments().getString("procInsId");
        bizId = getArguments().getString("bizId");

        mPresenter.receiptDocBizDetail(getActivity(),taskId,procInsId,bizId);

    }



    public static ReceiptDocDetailFragment newInstance(String taskId, String procInsId, String bizId) {
        ReceiptDocDetailFragment fragment = new ReceiptDocDetailFragment();
        Bundle bundle = new Bundle();
        bundle.putString("taskId", taskId);
        bundle.putString("procInsId", procInsId);
        bundle.putString("bizId", bizId);
        fragment.setArguments(bundle);
        return fragment;
    }

    @Override
    public void receiptDocBizDetail(final ReceiptDocDetailBean data) {

        if (null != data) {

            mainTitle.setText(data.getDetail().getNames()+"的收文审批");
            subheadTitle.setText(data.getDetail().getReceiptDate());
            if (null != data.getFiles() && data.getFiles().size() > 0) {

                enclosureLl.setVisibility(View.VISIBLE);
                enclosureNum.setText("["+data.getFiles().size()+"]");
                enclosure.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

                        MyDownLoadActivity.start(getActivity(),data.getFiles());

                    }
                });
            }

            name.setText(data.getDetail().getTitle());
            thingTitle.setText(data.getDetail().getSubjectwords());
            time.setText(data.getDetail().getLwCompany());
            pageNum.setText(data.getDetail().getLwNumber());
            copiesNum.setText(data.getDetail().getNames());
            voteMeet.setText(data.getDetail().getRetentionperiod());
            dutyPeople.setText(data.getDetail().getReceiptSequence());
            moneyMeet.setText(data.getDetail().getFileDate());
            windMeet.setText(data.getDetail().getReceiptDate());
            receiptNum.setText(data.getDetail().getCopies());
            receiptPage.setText(data.getDetail().getPages());


        }

    }


}
